{% extends "base.html" %}

{% block content %}

<div>
  {% with messages = get_flashed_messages(with_categories=true) %}
  {% if messages %}
  {% for category, message in messages %}
  {% if category == 'message' %}
  <div class="alert alert-warning" role="alert">
    {% else %}
    <div class="alert alert-{{ category }}" role="alert">
      {% endif %}
      {{ message }}
    </div>
    {% endfor %}
    {% endif %}
    {% endwith %}
  </div>

  <div class="row align-items-md-stretch">
    {% if not (global_config.farming_only or global_config.harvesting_only) %}
    <div class="col-md-6">
      <div class="h-20 p-2 bg-light border rounded-3">
        <h6 class="display-6 text-center">Plotting: {{ plotting.display_status }}</h6>
      </div>
    </div>
    {% endif %}
    {% if not (global_config.plotting_only or global_config.harvesting_only) %}
    <div class="col-md-6">
      <div class="h-20 p-2 bg-light border rounded-3">
        <h6 class="display-6 text-center">Farming: {{ farming.display_status }}</h6>
      </div>
    </div>
    {% endif %}
  </div>

  <br />

  <div class="row align-items-md-stretch">
    <div class="col-md-6">
      <div class="h-100 p-2 text-white bg-dark rounded-3">
        <h1 class="display-1 text-center text-success">{{ farming.plot_count }}</h1>
        <h6 class="display-6 text-center">Total Plots</h6>
      </div>
    </div>
    {% if not (global_config.plotting_only or global_config.harvesting_only) %}
    <div class="col-md-6">
      <div class="h-100 p-2 text-white bg-dark rounded-3">
        <h1 class="display-1 text-center text-success">{{ farming.total_chia }}</h1>
        <h6 class="display-6 text-center">Total Chia</h6>
      </div>
    </div>
    {% endif %}
  </div>

  <br />

  <div class="row align-items-md-stretch">
    <div class="col-md-6">
      <div class="h-100 p-2 text-white bg-dark rounded-3">
        <h4 class="display-4 text-center text-success">{{ farming.plot_size }}</h4>
        <h6 class="display-6 text-center">Total Plots Size</h6>
      </div>
    </div>
    {% if not (global_config.plotting_only or global_config.harvesting_only) %}
    <div class="col-md-6">
      <div class="h-100 p-2 text-white bg-dark rounded-3">
        <h4 class="display-4 text-center text-success">{{ farming.display_network_size }}</h4>
        <h6 class="display-6 text-center">Estimated Netspace Size</h6>
      </div>
    </div>
    {% endif %}
  </div>

  {% if not global_config.plotting_only %}
  <br />
  <div class="col-md-12">
    <div class="h-100 p-2 text-white bg-dark rounded-3">
      <table class="table table-dark">
        <thead>
          <tr>
            <th scope="col">Challenge</th>
            <th scope="col">Plots Passed Filter</th>
            <th scope="col">Proofs Found</th>
            <th scope="col">Time Taken</th>
            <th scope="col">Date</th>
          </tr>
        </thead>
        <tbody>
          {% for challenge in challenges.rows %}
          <tr>
            <td>{{challenge.challenge_id}}</td>
            <td>{{challenge.plots_past_filter}}</td>
            <td>{{challenge.proofs_found}}</td>
            <td>{{challenge.time_taken}}</td>
            <td>{{challenge.created_at}}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
  {% if challenges.rows|length == 0 %}
  <div class="text-center" style="padding-top:100 px; padding-bottom: 0px">
    <h6>No challenges found in Chia's log yet. Probably just starting up, syncing, or no plots yet...</h6>
    <h6>If you have plots and this persists long, check the Alerts tab and review Chia's log.  
      See the <a href="https://github.com/guydavis/machinaris/wiki/FAQ#why-are-there-no-challenges-shown-on-the-main-machinaris-page" target="_blank">FAQ.</a></h6>
  </div>
  {% endif %}

  {% endif %}

  {% endblock %}